// 函数的组合要满足结合律(associativity);
// 我们既可以把g和h组合, 还可以把f和g组合, 结果都是一样的;

//结合律
// let f = compose(f1, g, h);
// let associative = compose(compose(f1, g), h) == compose(f1, compose(g, h));
//true

const _ = require("lodash");

const f1 = _.flowRight(_.toUpper, _.first, _.reverse);
const f2 = _.flowRight(_.flowRight(_.toUpper, _.first), _.reverse);
const f3 = _.flowRight(_.toUpper, _.flowRight(_.first, _.reverse));

const text1 = f1(["one", "two", "three"]);
const text2 = f2(["one", "two", "three"]);
console.log(f1(["one", "two", "three"])); //THREE
console.log(f2(["one", "two", "three"])); //THREE
console.log(f3(["one", "two", "three"])); //THREE
console.log(text1 == text2); // true
